//
//  WWTabBarController.swift
//  -00 旺旺微博
//
//  Created by 伍良旺 on 16/4/16.
//  Copyright © 2016年 伍良旺. All rights reserved.
//

import UIKit

class WWTabBarController: UITabBarController {

   
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
       // self.tabBar.tintColor = UIColor.orangeColor()
        
        //通过KVC 将系统tabBar 改为 自定义
        let tabbar = WWTabbar()
        tabbar.wwDelegate = self
        setValue(tabbar, forKey: "tabBar")
        
        addChildViewController(WWHomeController(), imageNme: "tabbar_home", title: "首页")
        addChildViewController(WWMessageController(), imageNme: "tabbar_message_center", title: "信息")
        addChildViewController(WWDiscoverController(), imageNme: "tabbar_discover", title: "发现")
        addChildViewController(WWProfileController(), imageNme: "tabbar_profile", title: "我的")
    }

    func addChildViewController(childController: UIViewController, imageNme:String, title:String) {
        
        //设置图片
        childController.tabBarItem.image = UIImage(named: imageNme)
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageNme)_selected")
        //设置文字
        childController.title = title
    
        //添加
        addChildViewController(UINavigationController(rootViewController: childController))
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
// extension 相当于我们OC中的分类 extension 后面的类 CZMainViewController 就代表是当前类的分类
extension WWTabBarController: WWTabbarDelegate{
    
    func clickCenterBtn() {
        print("中间按钮被点击了")
    }
}

